import index from '@/views/index' 
import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const originalPush = Router.prototype.push
const originalReplace = Router.prototype.replace
// push
Router.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch((err) => err)
}
// replace
Router.prototype.replace = function push(location, onResolve, onReject) {
  if (onResolve || onReject) return originalReplace.call(this, location, onResolve, onReject)
  return originalReplace.call(this, location).catch((err) => err)
} 

export default new Router({
  routes: [
    {
      path: '/test',
      name: 'test',
      component: () => import("@/views/test.vue")
    },
    {
      path: '/',
      name: 'index',
      component: index, 
      children: [
        {
          path: "/overView",
          name: "overView",
          component: () => import("@/views/overView.vue")
        },
        {
          path: "/smartView",
          name: "smartView",
          component: () => import("@/views/smartView.vue")
        },
        {
          path: "/QuickTour",
          name: "QuickTour",
          component: () => import("@/views/QuickTour.vue")
        }, 
      ]
    } 
  ]
})
